<template>
	<div class="address">
		<slot name="one">
			<div class="title">
				<img src="../../public/arrow_left.png" alt="">
				<p class="users">新增地址</p>
			</div>
			<div class="con">
				<div class="news">
					<input type="text" placeholder="请填写你的姓名" v-model="name">
					<p v-show="nam">请填写你的姓名</p>
					<router-link to="search">
						<input type="text" placeholder="小区/写字楼/学校等" v-model="address">
					</router-link>
					
					<input type="text" placeholder="请填写详细送餐地址" v-model="address_detail    ">
					<p v-show="song">送餐地址太短了,不能辨识</p>
					<input type="text" placeholder="请填写能够联系到您的手机号" v-model="phone">
					<p v-show="tell">请输入正确的手机号</p>
					<input type="text" placeholder="备用联系电话(选填)" v-model="tel">
					<p v-show="shouji">请填写正确的手机号</p>
				</div>
				<button @click="add">新增地址</button>
				<div class="bj" v-show="isstatic">
					<div class="pop_up">
						<img src="../js/img/gantanhao.png" alt="" />
						<p>{{ test }}</p>
						<p class="sure" @click="sure">确认</p>
					</div>
				</div>
			</div>
			
			
		</slot>
	</div>
</template>

<script>
	export default {
		data:function(){
			return {
				nam:false,
				song:false,
				tell:false,
				shouji:false,
				isstatic:false,
				test:'',
				name:'',
				address_detail:'',
				address:'',
				phone:'',
				tel:'',
			}
		},
		methods:{
			sure: function() {
				this.isstatic = false;
			},
			add:function(){
				this.$axios({
					url:'https://elm.cangdu.org/v1/users/:user_id/addresses',
					method:'post',
					data:{
						name:this.name,
						address_detail:this.address_detail,
						address:this.address,
						phone:this.phone,
						tel:this.tel,
					}
				}).then(function(res){
					window.console.log(res)
				})
			}
		}
	}
</script>

<style scoped>
	.address {
		width: 320px;
		height: 568px;
		background-color: #F2F2F2;
	}
	.title {
		width: 320px;
		height: 39px;
		background-color: #3190E8;
		font-size: 16px;
		line-height: 39px;
		text-align: center;
	}
	
	.title span {
		display: inline-block;
		text-align: center;
		color: white;
	}
	.title p {
		display: inline-block;
		color: #FFFFFF;
	}
	.title img {
		width: 12px;
		height: 20px;
		float: left;
		margin-top: 10px;
		margin-left: 10px;
	}
	.con{
		width: 320px;
		height: 242px;
	}
	.news{
		width: 320px;
		height: 198px;
		background-color: #FFFFFF;
		margin-top: 10px;
		text-align: center;
	}
	input{
		color: black;
		/* color: #F2F2F2; */
		width: 300px;
		height: 30px;
		background-color: #F2F2F2;
		border-radius: 5px;
		margin-top: 7px;
		outline: none;
		border: none;
		text-indent: 10px;
	}
	button{
		width: 300px;
		height: 32px;
		background-color:#4CD96F;
		border-radius: 5px;
		border: none;
		color: white;
		margin-top: 10px;
		margin-left: 10px;
	}
	.bj {
		width: 320px;
		height: 568px;
		background-color: rgba(0, 0, 0, 0);
		/* background-color: #000000; */
		position: fixed;
		top: 0;
		left: 0;
	}
	
	.pop_up {
		width: 240px;
		height: 158px;
		background: white;
		border-radius: 10px;
		top: 200px;
		left: 40px;
		position: fixed;
		text-align: center;
	}
	
	.pop_up img {
		height: 60px;
		width: 60px;
		margin-top: 20px;
		/* padding-top: 40px; */
	}
	
	.sure {
		width: 240px;
		height: 36px;
		line-height: 36px;
		color: white;
		background-color: #4cd964;
		border-radius: 5px;
		margin-top: 35px;
		font-size: 20px;
	}
	
	.test {
		display: inline-block;
		position: fixed;
		right: 10px;
		padding: 20px 20px;
	}
	
	a {
		text-decoration: none;
	}
	p{
		float: left;
		margin-left: 20px;
		color: red;
	}
</style>
